/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 * NuGat-API named Chameleon developed by Simon De Baets to Verimag.
 *
 */
package chameleon.view.command;

import chameleon.model.NuGatManager.NuGatManager;
import chameleon.view.input.Input;
import java.io.File;

/**
 * Only NuGaT commands
 * @author simon
 */
class ModifyOrderStrategyCommand extends Command {

    private String fileOrder_;
    
    public ModifyOrderStrategyCommand(Input input, String file, boolean help) {
        super(input,false,help);
        fileOrder_ = file;
    }

    @Override
    public Input execute() {
        if(help_){
            outputManager_.displayString(""
                    + "modify_order_strategy [-filename | -h ]\n"
                    + "modify the order of the bdd's composed the strategy.\n"
                    + "The syntax to this file is the same as a NuSmv order file"
                    + "\n");
        }
        else{
            
            InternalCheckCommand check = new InternalCheckCommand(input_, 3);
            if (check.isOk()){
                NuGatManager manager = (NuGatManager) input_.getManager();
                if (manager.strategyExists()){
                    File file = new File(fileOrder_);
                    if (file.isFile())
                        manager.modifyOrderStrategy(fileOrder_);
                    else
                        outputManager_.displayString("It's not a file, please try again!\n");
                }
                else
                    outputManager_.displayString("No strategy present in structure!\n"
                            + "Please use compute_strategy.\n");
            }
        }
        return input_;
    }
    
}
